/* Moral, Mert, and Efe Tokdemir 
�Justices `en Garde'_Ideological Determinants of the Dissolution of Anti-Establishment Parties� 
International Poltiical Science Review
Replication File
10.26.2015 */

** ANALYSES
** In-text Table and Figures
* Table 1
cd "/Users/mmoral/Dropbox/SUNY Binghamton PhD/Miscellaneous/Constitutional Court/Replication/To be Published Online/"
use "Replication Data.dta", clear
eststo m1:logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education, robust cluster(jid)
eststo m2:logit vote i.pfamily sclr_parl parl2 parlbalance position experience education, robust cluster(jid)
esttab m1 m2 using "table1.tex", tex replace b(%10.3f) se stats(N ll r2_p, labels("N" "Pseudo R$^{2}$" "Log lik.") fmt(%10.0f %10.3f %10.3f)) label starlevels(* 0.1 ** 0.05 *** 0.01) ///
varlabels(_cons Constant) addnote("Robust standard errors clustered by justices in parentheses. Two-tailed tests.") alignment(l) nonote nogaps nodepvars nonumbers compress noomit nobase mtitle("Model 1" "Model 2")

* Figure 1 
foreach i in -1 0 1 {
local j=`i'+2
logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education, robust cluster(jid)
margins, at(coord1d_jr=`i' coord2d_jr=(-1(1)1) pfamily=2 parl2=0 position=2 education=1) atmeans post
est sto mg`j'2
logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education, robust cluster(jid)
margins, at(coord1d_jr=`i' coord2d_jr=(-1(1)1) pfamily=0 parl2=0 position=2 education=1) atmeans post
est sto mg`j'0
}
coefplot (mg10, label(1st Dimension=-1) fcolor(gs12)) (mg20, label(1st Dimension=0) fcolor(gs8)) (mg30, label(1st Dimension=1) fcolor(gs4)), recast(bar) barwidth(0.2) ///
ciopts(recast(rcap)) citype(logit) vertical citop xlabel(1 "-1" 2 "0" 3 "1") xtitle("2nd Dimension (w-nominate)") title("Fringe Parties") ylabel(0(0.2)1) ///
ytitle("Pr(Vote for Dissolution)") legend(rows(1) order(1 "1st Dimension=-1" 3 "1st Dimension=0" 5 "1st Dimension=1")) nodraw name(Grm1, replace)
coefplot (mg12, label(1st Dimension=-1) fcolor(gs12)) (mg22, label(1st Dimension=0) fcolor(gs8)) (mg32, label(1st Dimension=1) fcolor(gs4)), recast(bar) barwidth(0.2) ///
ciopts(recast(rcap)) citype(logit) vertical citop xlabel(1 "-1" 2 "0" 3 "1") xtitle("2nd Dimension (w-nominate)") title("Ethnic Parties") ylabel(0(0.2)1) ///
ytitle("Pr(Vote for Dissolution)") legend(rows(1) order(1 "1st Dimension=-1" 3 "1st Dimension=0" 5 "1st Dimension=1")) nodraw name(Grm2, replace)
grc1leg Grm1 Grm2, ycommon legendfrom(Grm2) scale(.75) saving(Figure1.gph, replace)

* Figure 2
foreach i in 0 2 {
logit vote i.pfamily sclr_parl parl2 parlbalance position experience education, robust cluster(jid)
margins, at(sclr_parl=(-.35(.05)1) pfamily=`i' parl2=0 position=2 education=1) atmeans post 
est store mg`i'
}
coefplot (mg0, color(gs0) lpattern(shortdash)) (mg2, color(gs0) lpattern(shortdash) offset(-.025)), recast(line) ciopts(recast(rarea)) ///
vertical xlabel(1 "-0.35" 8 "0" 15 "0.35" 22 "0.7" 28 "1") xtitle("Mean Left-Right Score") scale(.75) ylabel(0(0.2)1) ytitle("Pr(Vote for Dissolution)") ///
legend(order(1 "Fringe Parties" 3 "Ethnic Parties")) saving(Figure2.gph, replace) 

** Supplementary File
* C. Descriptive Statistics
tab pfamily, gen(pe)
sutex vote sclr_parl coord1d_jr coord2d_jr parl2 parlbalance position experience education pe*, labels minmax nobs file(descriptive.tex) replace
quietly logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education if procedural==0, robust cluster(case)
sutex vote sclr_parl coord1d_jr coord2d_jr parl2 parlbalance position experience education pe* if e(sample)==1, labels minmax nobs file(descriptive.tex) append

* D. Robustness Checks
eststo m3:logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education, robust cluster(case)
eststo m4:logit vote i.pfamily sclr_parl parl2 parlbalance position experience education, robust cluster(case)
eststo m5:logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education if procedural==0, robust cluster(case)
eststo m6:logit vote i.pfamily sclr_parl parl2 parlbalance position experience education if procedural==0 & e(sample), robust cluster(case)
esttab m3 m4 m5 m6 using "robust.tex", tex replace b(%10.3f) se stats(N ll r2_p, labels("N" "Pseudo R$^{2}$" "Log lik.") fmt(%10.0f %10.3f %10.3f)) label starlevels(* 0.1 ** 0.05 *** 0.01) ///
varlabels(_cons Constant) addnote("DV is Vote for Dissolution. Logistic regression coefficients. Robust standard errors clustered by cases in parentheses. Two-tailed tests.") ///
alignment(l) nonote nogaps nodepvars nonumbers compress noomit nobase mtitle("Model 1" "Model 2" "Model 3" "Model 4")

* Figure 3
coefplot (m1,label(Model.1) mcolor(black) pstyle(p3) msymbol(smdiamond)) (m2,label(Model.2) mcolor(gs12) pstyle(p3) msymbol(smsquare)), bylabel(Full Sample) || ///
(m5,label(Model.5) mcolor(black) pstyle(p3) msymbol(smdiamond)) (m6,label(Model.6) mcolor(gs12) pstyle(p3) msymbol(smsquare)) ///
, drop(_cons) xline(0) msize(small) bylabel(Non-procedural Cases) order(sclr_parl coord1d_jr coord2d_jr 1.pfamily 2.pfamily 3.pfamily 4.pfamily 5.pfamily parl2 parlbalance position experience education) /// 
coeflabel(1.pfamily="Socialist/Communist Party" 2.pfamily="Kurdish/Alevi Party" 3.pfamily="Center Party" 4.pfamily="Nationalist Party" 5.pfamily="Religious Party") legend(rows(1)) ///
groups(sclr_parl coord1d_jr coord2d_jr= "Justice Ideology" ?.pfamily="Party Families" parl2 parlbalance="Public Opinion" position experience education="Controls", ///
wrap(12) angle(90) labsize(small)) plotlabels("Model.1 & Model.5" "Model.2 & Model.6") xlabel(,labsize(small)) ylabel(,labsize(small)) scale(.65) saving(Figure3.gph, replace)

* Sensitivity Checks
logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education i.presapn, robust
logit vote i.pfamily sclr_parl parl2 parlbalance position experience education i.presapn, robust
logit vote i.pfamily coord1d_jr coord2d_jr parl2 parlbalance position experience education i.presapn i.entry, robust
logit vote i.pfamily sclr_parl parl2 parlbalance position experience education i.presapn i.entry, robust

forval i=1/3 {
graph use Figure`i'.gph
graph export Figure`i'.pdf, replace
}
